package com.stars.empoly.activity

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.qmuiteam.qmui.widget.tab.QMUITab
import com.qmuiteam.qmui.widget.tab.QMUITabBuilder
import com.stars.empoly.base.MBTabActivity
import com.stars.empoly.databinding.ActivityMyOrderBinding
import com.stars.empoly.fragment.CustomerOrderListFragment
import com.stars.empoly.vmodel.CustomerOrderVModel
import com.trailer.base.utils.B


/**
 * 货主订单
 */
class CustomerOrderActivity: MBTabActivity<CustomerOrderVModel, ActivityMyOrderBinding>() {
    var type = 0

    override fun createTabs(tabBuilder: QMUITabBuilder): Array<QMUITab> {
        val component = tabBuilder
                .setText("全部")
                .build(context())

//        val two = tabBuilder
//                .setText("待接单")
//                .build(context())
        val util = tabBuilder
                .setText("进行中")
                .build(context())

        val complete = tabBuilder
                .setText("已完成")
                .build(context())

        return arrayOf(component, util, complete)
    }

    override fun vmClass(): Class<CustomerOrderVModel> {
        return CustomerOrderVModel::class.java

    }

    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)

//        titleBar()?.tvRight?.text="筛选"
//        titleBar()?.tvRight?.setTextColor(Color.parseColor("#28292A"))


    }






    override fun binding(): ActivityMyOrderBinding {
        return ActivityMyOrderBinding.inflate(layoutInflater)
    }

    override fun getPageItem(position: Int): Fragment {


        var ownerFragment = CustomerOrderListFragment()
        when (position) {
            0 -> {
                ownerFragment.arguments = B().putString("order_state", "0").ok()
                return ownerFragment
            }

            1 -> {
                ownerFragment.arguments = B().putString("order_state", "1").ok()
                return ownerFragment

            }
            2 -> {
                ownerFragment.arguments = B().putString("order_state", "2").ok()
                return ownerFragment

            }
//            3 -> {
//                ownerFragment.arguments = B().putString("order_state", "2").ok()
//                return ownerFragment
//
//            }

            else->{
                ownerFragment.arguments = B().putString("order_state", "0").ok()
                return ownerFragment
            }

        }


    }

    override fun getPageCount(): Int {
        return 4
    }
    override fun title(): String? {
        return "我的订单"
    }








}
